<!Doctype html>
<html xmlns=http://www.w3.org/1999/xhtml>

<head>
  <meta http-equiv="Content-Type" content="text/html;charset=utf8">
  <meta charset="utf-8">
  <meta name="viewport"
    content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <meta content=always name=referrer>
  <meta http-equiv=X-UA-Compatible content="IE=edge,chrome=1">
  <meta name="description" content="">
  <meta name="keywords" content="">
  <title>echart</title>
  <script type="text/javascript" src="../js/echarts.min.js"></script>
  <style type="text/css">
    body,
    html,
    #echart {
      height: 100%;
    }

    * {
      margin: 0;
      padding: 0;
    }
  </style>
</head>


<body>
  <div id="echart"></div>

  <script type="text/javascript">
    var myChart;
    var init = false;
      initWebView();
      var mainContainer = document.getElementById('echart');
      //用于使chart自适应高度和宽度,通过窗体高宽计算容器高宽
      var resizeMainContainer = function () {
        mainContainer.style.width = window.innerWidth + 'px';
        mainContainer.style.height = window.innerHeight + 'px';
      };
      //设置div容器高宽
      resizeMainContainer();
      $(window).on('resize', function () {
        //屏幕大小自适应，重置容器高宽
        resizeMainContainer();
        myChart.resize();
      });
      myChart = echarts.init(mainContainer);

      myChart.on('finished', function () {
        callHandler('isFinished');
      });


    // // 使用刚指定的配置项和数据显示图表。
    function setOption(optionJson) {
      if (!myChart) {
        return;
      }
      var option = JSON.parse(JSON.stringify(optionJson));
      if (option && typeof option === 'object') {
        myChart.setOption(option);
      }
    }


    //初始化flutterWebview
    function initWebView() {
      window.addEventListener('flutterInAppWebViewPlatformReady', function (event) {
      });
      callHandler('init');
    }


    function callHandler(methodName) {
      try {
        window.flutter_inappwebview.callHandler(methodName, true);
      } catch (error) {
        window.addEventListener('flutterInAppWebViewPlatformReady', function (event) {
          window.flutter_inappwebview.callHandler(methodName, true);
        });
      }
    }
  </script>
</body>

</html>